package cn.hsw.manage.permission.mapper;

import cn.hsw.manage.permission.entity.Permission;
import cn.hsw.manage.permission.vo.MenuInfoVo;
import cn.hsw.manage.permission.vo.PermissionDetailVO;
import cn.hsw.manage.permission.vo.PermissionTreeVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 李子木
 * @since 2021-11-03 08:56:37
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    Set<String> getPermissionsSetByUserPid(@Param("userPid")Long userPid,@Param("type") int type);

    @Select("select * from hsw_manage_permission where parent_pid = #{parentPid}")
    List<Permission> findByparentPid(@Param("parentPid") Long parentPid);

    @Select("select * from hsw_manage_permission where code = #{code}")
    Permission findByCode(@Param("code")String code);

    @Select("select * from hsw_manage_permission where parent_pid is null")
    List<Permission> findByParentPidNull();

    List<MenuInfoVo> findByTypeNotAndStateAndUserPid(@Param("type") int type, @Param("state") int state, @Param("userPid") Long currUserPid);

    PermissionDetailVO findByPid(@Param("pid") Long pid);

    List<PermissionTreeVO> selectByTypeIn(@Param("typeList") List<Integer> typeList);
}
